/*
 ============================================================================
 Name		: DocListEngine.h
 Author	  : JohnLZeng
 Version	 : 1.0
 Copyright   : Your copyright notice
 Description : CDocListEngine declaration
 ============================================================================
 */

#ifndef DOCLISTENGINE_H
#define DOCLISTENGINE_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include <BADESCA.H>

#include "EngineDef.h"
#include "RSSBriefData.h"
#include "QWString.h"
#include "cx_typedef.h"
#include "cx_tinydb.h"
#include "QStoreFile.h"

// CLASS DECLARATION

/**
 *  CDocListEngine
 * 
 */
class CDocListEngine : public CBase
	{
public:
	// Constructors and destructor

	/**
	 * Destructor.
	 */
	~CDocListEngine();

	/**
	 * Two-phased constructor.
	 */
	static CDocListEngine* NewL();

	/**
	 * Two-phased constructor.
	 */
	static CDocListEngine* NewLC();

private:

	/**
	 * Constructor for performing 1st stage construction
	 */
	CDocListEngine();

	/**
	 * EPOC default constructor for performing 2nd stage construction
	 */
	void ConstructL();
	
public:
	void Init();
	void Release();
	
	TInt GetAll(ArrayDocList& aArray);
	TInt GetByState(ArrayDocList& aArray);
	TInt GetRange(ArrayDocList& aArray,const TInt& aPos,const TInt& aLength);
	TInt Save(ArrayDocList& aArray,CRSSBriefData* aItem);
	TInt Save(const ArrayDocList& aArray);
	
	TInt Add(ArrayDocList& aArray,const TInt& aPos,CRSSBriefData* aItem);
	
	CRSSBriefData* AppendToList(ArrayDocList& aArray,const TDesC& aTitle);
	TInt RemoveFromList(ArrayDocList& aArray,const TInt& aIndex);
	
	void ClearAll(ArrayDocList& aArray);
	
	TInt ConvertToListFormat(const ArrayDocList& aArray,CDesCArray* aDesC);
	TInt ConvertToListFormat(CRSSBriefData* aItem,TDes& aFormat);

private:
	CQStoreFile iStoreFile;
	};

#endif // DOCLISTENGINE_H
